package com.gitee.cui.es;

import java.io.IOException;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

/**
 * ES索引删除操作
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022-04-05 15:56
 **/
public class ESIndexDelete {

	public static void main(String[] args) throws IOException {
		RestHighLevelClient client = new RestHighLevelClient(
				RestClient.builder(new HttpHost("localhost", 9200, "http")));

		// 删除索引
		DeleteIndexRequest deleteUser = new DeleteIndexRequest("user");
		AcknowledgedResponse response = client.indices().delete(deleteUser, RequestOptions.DEFAULT);
		System.out.println(response.isAcknowledged());
		client.close();
	}
}
